package org.gnyxy.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.gnyxy.entity.Address;
import org.gnyxy.vo.AddressVO;

import java.util.List;

@Mapper
public interface AddressMapper {
    @Insert("insert into address (user_id, consignee, sex, phone, address_detail, label, id_default, deleted) VALUES " +
            "(#{userId},#{consignee},#{sex},#{phone},#{addressDetail},#{label},#{idDefault},#{deleted})")
    void insert(Address address);

    @Select("select * from address where deleted = 0 and user_id = #{userId} ")
    List<AddressVO> selectByUserId(Long userId);

    @Select("select * from address where deleted = 0 and user_id = #{userId} and id_default = 1")
    AddressVO selectDefaultByUserId(Long userId);

    @Select("select * from address where deleted = 0 and id =#{id}")
    AddressVO selectById(Long id);

    void update(Address address);


}
